<?php
namespace app\admin\command;

use think\console\Command;
use think\console\Input;
use think\console\Output;
use app\common\model\GoodsModel;

class Online extends Command {

    protected function configure() {
        $this->setName('online')->setDescription('定时上线');
    }

    protected function execute(Input $input, Output $output) {
        $where = [
            'isshow'=>2,
            'online_time '=>['between',[time()- 3600,time()]],
        ];
        //现在时刻一小时前的都会上线
        $ids = GoodsModel::instance()->where($where)->column('id');
        foreach ($ids as $id){
            GoodsModel::instance()->update(['id'=>$id,'isshow'=>1,'online_time'=>0]);
        }
        
    }
    
    
}